package com.service;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

/**
 * 定时服务类
 */
@Service
public class TimeTaskService {

    @Autowired
    private RedisTemplate  redisTemplate;

    /**
     * 每隔5秒去删除过期的zset中的value
     */
     @Scheduled(cron = "0/5 * * * * ?")
     public void removeExpireMailCode()
     {
           redisTemplate.boundZSetOps("mail").removeRangeByScore(0, System.currentTimeMillis()-30*60*1000);
     }
}
